<?php
declare(strict_types=1);

namespace App\Controller\WebSocket;

use App\Services\EnterService;
use Hyperf\Contract\OnCloseInterface;
use Hyperf\Contract\OnMessageInterface;
use Hyperf\Contract\OnOpenInterface;
use Swoole\Http\Request;
use Swoole\Websocket\Frame;

class WebSocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface
{

    public function onMessage($server, Frame $frame): void
    {
        EnterService::message($frame, $server);
    }

    public function onClose($server, int $fd, int $reactorId): void
    {
        EnterService::close($server, $fd);
    }

    public function onOpen($server, Request $request): void
    {
        EnterService::open($server, $request);
    }
}